//
//  StatusCellBottomView.swift
//  sinaweibowj
//
//  Created by Macintosh on 15/12/20.
//  Copyright © 2015年 mactoinsh. All rights reserved.
//

import UIKit
import SnapKit

class StatusCellBottomView: UIView {
    
    @objc private func commentBtnClick() {
    
    let temp = TempViewController()
        
        //隐藏BottomBar按钮，要在push上一个控制器修改 push后一个控制器的属性
        //temp.hidesBottomBarWhenPushed = true
        
        self.navController()?.pushViewController(temp , animated: true)
        
    }
    
    
    //MARK:定义外部模型属性
    
    
    //MARK:重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK:设置页面和布局
    private func setupUI(){
        //添加子视图
        addSubview(retweetedBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        
        
        //添加约束
        //三等分视图第一步，两边贴边对齐 设置等宽
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.top.left.bottom.equalTo(self)
            make.right.equalTo(commentBtn.snp_left)
           // make.width.equalTo(commentBtn.snp_width)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.equalTo(self)
            make.left.equalTo(retweetedBtn.snp_right)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.right.equalTo(self)
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(commentBtn.snp_width)
        }
        
        let sepView1 = sepView()
        let sepView2 = sepView()
        
        //添加分割视图
        addSubview(sepView1)
        addSubview(sepView2)
        
        let w :CGFloat = 0.5
        let scale :CGFloat = 0.4
        
        //添加分割视图约束
        sepView1.snp_makeConstraints { (make) -> Void in
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.centerX.equalTo(retweetedBtn.snp_right)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
            make.centerY.equalTo(self.snp_centerY)
            make.centerX.equalTo(commentBtn.snp_right)
        }

        //点击事件
        commentBtn.addTarget(self, action: "commentBtnClick", forControlEvents: .TouchUpInside)
        
        
    }
    
    //生成分割视图
    private func  sepView() -> UIView{
    
    let v = UIView()
    v.backgroundColor = UIColor.darkGrayColor()
    return v
        
    }
    
    //MARK:懒加载所有的子视图
    //转发按钮 retweetedBtn
    private lazy var retweetedBtn:UIButton = UIButton(title: "转发", backgroundImage: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
    //评论按钮 commentBtn
    private lazy var commentBtn:UIButton = UIButton(title: "评论", backgroundImage: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
    //点赞按钮 likeBtn
    private lazy var likeBtn:UIButton = UIButton(title: "赞", backgroundImage: nil, fontSize: 10, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")
}
